import { boot } from 'quasar/wrappers'
import { useCommonStore } from 'stores/commonStore';
import { storeToRefs } from 'pinia';

export default boot(({ router, store }) => {
  //commonStore
  const commonStore = useCommonStore();
  const {
    token
  } = storeToRefs(commonStore)

  //启动提示
  console.log('boot/guide!');

  //路由守卫
  router.beforeEach((to, from, next) => {
    //获取token;
    commonStore.getToken();

    //路由判断
    if (!token.value) {
      if (to.path === '/auth/login') {
        next();
      } else {
        next('/auth/login');
      }
    } else {
      next();
    }
  })
})
